#include <cmath>
#include "my_math.h"

const int sin_N = 62832;
double sin_table[sin_N];

double my_sin(double x)
{
    static bool is_initialized = false;
    static double M_2PI = 2 * M_PI;
    if (is_initialized)
    {
        x -= M_2PI * floor(x / M_2PI);
        return sin_table[int(10000 * x)];
    }
    else
    {
        for (int i = 0; i < sin_N; i++)
            sin_table[i] = sin(M_2PI * double(i) / sin_N);
        is_initialized = true;
        return sin(x);
    }
}